home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-19 / gpt32src.zip / CHECKDOC.C < prev    next >
C/C++ Source or Header  |  1992-03-25  |  2KB  |  74 lines

  1. #ifndef lint
  2. static char *RCSid = "$Id: checkdoc.c,v 3.26 1992/03/25 04:53:29 woo Exp woo $";
  3. #endif
  4.  
  5. /*
  6.  * checkdoc -- check a doc file for correctness of first column. 
  7.  *
  8.  * Prints out lines that have an illegal first character.
  9.  * First character must be space, digit, or ?, @, #, %, 
  10.  * or line must be empty.
  11.  *
  12.  * usage: checkdoc < docfile
  13.  * Modified by Russell Lang from hlp2ms.c by Thomas Williams 
  14.  *
  15.  * Original version by David Kotz used the following one line script!
  16.  * sed -e '/^$/d' -e '/^[ 0-9?@#%]/d' gnuplot.doc
  17.  *
  18.  */
  19.  
  20. #include <stdio.h>
  21. #include <ctype.h>
  22.  
  23. #define MAX_LINE_LEN    256
  24. #define TRUE 1
  25. #define FALSE 0
  26.  
  27. main()
  28. {
  29.     convert(stdin,stdout);
  30.     exit(0);
  31. }
  32.  
  33. convert(a,b)
  34.     FILE *a,*b;
  35. {
  36.     static char line[MAX_LINE_LEN];
  37.  
  38.     while (fgets(line,MAX_LINE_LEN,a)) {
  39.        process_line(line, b);
  40.     }
  41. }
  42.  
  43. process_line(line, b)
  44.     char *line;
  45.     FILE *b;
  46. {
  47.     switch(line[0]) {        /* control character */
  48.        case '?': {            /* interactive help entry */
  49.           break;            /* ignore */
  50.        }
  51.        case '@': {            /* start/end table */
  52.           break;            /* ignore */
  53.        }
  54.        case '#': {            /* latex table entry */
  55.           break;            /* ignore */
  56.        }
  57.        case '%': {            /* troff table entry */
  58.           break;            /* ignore */
  59.        }
  60.        case '\n':            /* empty text line */
  61.        case ' ': {            /* normal text line */
  62.           break;
  63.        }
  64.        default: {
  65.           if (isdigit(line[0])) { /* start of section */
  66.                   /* ignore */
  67.           } else
  68.             fputs(line,b);    /* output bad line */
  69.           break;
  70.        }
  71.     }
  72. }
  73.  
  74.